package com.atguigu.singleton.type8;

/**
 * 使用枚举的特性,也可以创建单例
 */
enum SingleTon {
    INSTANCE;

    public void sayOk() {
        System.out.println("ok");
    }
}

/**
 * @ClassName SingleTon08
 * @Description TODO
 * @Author HongJian-Yang
 * @Date 2020/6/16 23:18
 * @Version 1.0
 */
public class SingleTon08 {
    public static void main(String[] args) {
        SingleTon instance1 = SingleTon.INSTANCE;
        SingleTon instance2 = SingleTon.INSTANCE;
        System.out.println(instance1 == instance2);

        instance1.sayOk();
    }
}
